package com.example.foodisimportant;

import android.os.Looper;
import android.widget.Toast;

import com.example.foodisimportant.RegisterActivity.RegisterTest;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;

public class store {
    //进行数据的传递
    /*try {
        URL url =new URL(URL_LOGIN);

        HttpURLConnection conn = (HttpURLConnection) url.openConnection();

        conn.setRequestMethod("POST"); //设置请求方式为post

        conn.setReadTimeout(5000);//设置超时信息
        conn.setConnectTimeout(7000);//设置超时信息

        conn.setDoInput(true);//设置输入流，允许输入
        conn.setDoOutput(true);//设置输出流，允许输出
        conn.setUseCaches(false);//设置POST请求方式不能够使用缓存

        String data = "flag=register"+"&i="+id+"&n=" + name + "&p=" + pwd + "&c="+campus;

        OutputStream out = conn.getOutputStream();

        out.write(data.getBytes());

        out.flush();

        out.close();

        BufferedReader reader = new BufferedReader(new InputStreamReader(
                conn.getInputStream()));
        String line = null;
        if ((line = reader.readLine()) != null) {
                                 /*
                                   如果数据比较多的话要把if换成while，循环体代码也要小改一下，
                                    由于我当时只是测试，就没改
                                  */
    /* flag = line;

        }
    } catch (
    IOException e) {
        e.printStackTrace();
    }
    String msg = "";
                            if(flag.equals("true")) msg = "注册成功";
                            else msg = "注册失败";
                            Looper.prepare();
                            Toast.makeText(RegisterTest .this, msg, Toast.LENGTH_SHORT).show();
                            Looper.loop();
                            */}
